package com.hs.service;

import com.hs.config.PageObj;
import com.hs.dao.NewsMapper;
import com.hs.entity.News;
import com.hs.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsService {
    @Autowired
    NewsMapper newsMapper;


    public List<News> selectByCondition(News record){
        return newsMapper.selectByCondition(record);

    }

    public int insertSelective(News record){
     return newsMapper.insertSelective(record);
    }
    public int selectByConditionCount(News record){
     return newsMapper.selectByConditionCount(record);
    }
    public PageObj page(News item){
        int total = newsMapper.selectByConditionCount(item);
        if(total == 0){
            return new PageObj(item.getCurrentPage(), item.getPageSize(),total,null);
        }
        List<News> list = newsMapper.selectByCondition(item);
        return new PageObj(item.getCurrentPage(), item.getPageSize(),total,list);
    }




}
